import { RegularExpression } from '@/common/constVariable';
import { useDescriptionsType } from '@/components/DescriptionsType';
import { Select } from 'antd';
import { useEffect } from 'react';

const getLeaseHouseUpdateConfig = ({ pageType, record, assetLeaseHouseForm, mapLoading, assetAcquireType }) => {
  useEffect(() => {
    /** 回填表单 */
    if (pageType === 'view' || pageType === 'edit') {
      assetLeaseHouseForm?.setFieldsValue({
        ...record.assetjson,
      });
    }
  }, [record]);

  const [leaseHouseConfig, leaseHouseMethods] = useDescriptionsType({
    labelWidth: 190,
    basicForm: assetLeaseHouseForm,
    name: 'accept-assetLeaseHouseForm',
    schemas: [
      {
        key: 'accept-null',
        title: '',
        fieldChildren: [],
      },
      {
        key: 'accept-info',
        title: '材料信息',
        fieldChildren: [
          {
            field: `ledgerAccount`,
            label: `单位会计科目`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请输入',
            required: true,
          },
          {
            field: `obtainType`,
            label: `取得方式`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请选择',
            required: true,
            render: (text) => {
              return (
                <Select
                  loading={mapLoading}
                  options={assetAcquireType}
                  disabled={pageType === 'view'}
                  placeholder="请选择"
                  fieldNames={{
                    label: 'name',
                    value: 'id',
                  }}
                />
              );
            },
          },
          {
            field: `entryState`,
            label: `财务入账状态`,
            component: 'Render',
            disabled: pageType === 'view',
            required: true,
            render: (text) => {
              return (
                <Select
                  options={[
                    {
                      label: '未入账',
                      value: 0,
                    },
                    {
                      label: '已入账',
                      value: 1,
                    },
                  ]}
                  disabled={pageType === 'view'}
                  placeholder="请选择"
                />
              );
            },
          },
          {
            field: `usedType`,
            label: `资产用途`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请输入',
            required: true,
          },
          {
            field: `subjectToliability`,
            label: `使用责任主体`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请输入',
            required: true,
          },
          {
            field: `position`,
            label: `坐落位置`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请输入',
            required: true,
          },
          {
            field: `inUseAreaWorkSpace`,
            label: `在用面积：办公用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `inUseAreaOfficeSpace`,
            label: `在用面积：办公室用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `inUseAreaBusinessSpace`,
            label: `在用面积：业务用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `inUseAreaOtherSpace`,
            label: `在用面积：其他用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `useAreaWorkSpace`,
            label: `实际使用面积：办公用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `useAreaOfficeSpace`,
            label: `实际使用面积：办公室用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `useAreaBusinessSpace`,
            label: `实际使用面积：业务用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `useAreaOtherSpace`,
            label: `实际使用面积：其他用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `unusedAreaWorkSpace`,
            label: `闲置面积：办公用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `unusedAreaOfficeSpace`,
            label: `闲置面积：办公室用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `unusedAreaBusinessSpace`,
            label: `闲置面积：业务用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `unusedAreaOtherSpace`,
            label: `闲置面积：其他用房`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: 'm²',
            pattern: RegularExpression?.twoFloatNumber,
            patternMsg: '请输入整数或保留两位小数',
          },
          {
            field: `contractCode`,
            label: `租赁合同编号`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请输入',
            required: true,
          },
          {
            field: `contractName`,
            label: `租赁合同名称`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请输入',
            required: true,
          },
          {
            field: `contractMoneny`,
            label: `租赁合同金额`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: '元',
            required: true,
            pattern: RegularExpression?.number,
            patternMsg: '请输入整数',
          },
          {
            field: `contractYearRent`,
            label: `合同年租金`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: '元',
            pattern: RegularExpression?.number,
            patternMsg: '请输入整数',
          },
          {
            field: `rentStandard`,
            label: `租金标准`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: '元/平方米·月',
            pattern: RegularExpression?.number,
            patternMsg: '请输入整数',
          },
          {
            field: `rentTerm`,
            label: `租赁期限`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            contentAfter: '月',
            pattern: RegularExpression?.number,
            patternMsg: '请输入整数',
            required: true,
          },
          {
            field: `rentBeginDate`,
            label: `租赁开始日期`,
            component: 'DatePicker',
            disabled: pageType === 'view',
            format: 'YYYY-MM-DD',
            placeholder: '请选择',
            required: true,
          },
          {
            field: `rentEndDate`,
            label: `租赁结束日期`,
            component: 'DatePicker',
            disabled: pageType === 'view',
            format: 'YYYY-MM-DD',
            placeholder: '请选择',
            required: true,
          },
          {
            field: `leaserUnitName`,
            label: `出租方单位名称`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请输入',
            required: true,
          },
          {
            field: `leaserUnitPerson`,
            label: `出租方单位联系人`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请输入',
            required: true,
          },
          {
            field: `leaserPhone`,
            label: `出租方联系电话`,
            component: 'InputNumber',
            placeholder: '请输入',
            disabled: pageType === 'view',
            min: 0,
            // contentAfter: '月',
            pattern: RegularExpression?.phone,
            patternMsg: '请输入正确的手机号',
            required: true,
          },
          {
            field: `denseState`,
            label: `定密状态`,
            component: 'Render',
            disabled: pageType === 'view',
            required: true,
            render: (text) => {
              return (
                <Select
                  options={[
                    {
                      label: '未定密',
                      value: 0,
                    },
                    {
                      label: '已定密',
                      value: 1,
                    },
                  ]}
                  disabled={pageType === 'view'}
                  placeholder="请选择"
                />
              );
            },
          },
          {
            field: `denseDate`,
            label: `定密时间`,
            component: 'DatePicker',
            disabled: pageType === 'view',
            format: 'YYYY-MM-DD',
            placeholder: '请选择',
            required: true,
          },
          {
            field: `longTime`,
            label: `是否长期`,
            component: 'Render',
            disabled: pageType === 'view',
            required: true,
            render: (text) => {
              return (
                <Select
                  options={[
                    {
                      label: '是',
                      value: 1,
                    },
                    {
                      label: '否',
                      value: 0,
                    },
                  ]}
                  disabled={pageType === 'view'}
                  placeholder="请选择"
                />
              );
            },
          },
          {
            field: `secrecyTerm`,
            label: `保密期限`,
            disabled: pageType === 'view',
            component: 'Input',
            placeholder: '请选择',
            required: true,
          },
        ],
      },
    ],
  });

  return {
    leaseHouseConfig,
    leaseHouseMethods,
  };
};

export { getLeaseHouseUpdateConfig };
